<?php
namespace Andorra\dao;

class EntityType {
	public $name, $setName, $className;
	public $key, $generator;
	public $columns = array();
	
	public function __construct(\DOMElement $elem) {
		$this->name = $elem->getAttribute('name');
		
		if (($this->setName = $elem->getAttribute('setName')) == '')
			$this->setName = $this->name . 's';
		
		if (($this->className = $elem->getAttribute('className')) == '')
			$this->className = $this->name;
		
		$keyElem = $elem->childNodes->item(1);
		$this->key = $keyElem->textContent;
		$this->generator = $keyElem->getAttribute('generator');
		
		$columnElems = $elem->getElementsByTagName('column');
		foreach ($columnElems as $ce)
			$this->columns[] = $ce->textContent;
	}
}
?>